
// //统计考试科目的成绩

function statistics() {
    let all = 0;
    let num, i;
    num = prompt('请输入考试科目数量：');
    if (isNaN(num) || num <= 0) {
        alert('输入错误，请输入正确数量！');
        return;
    }
    for (i = 1; i <= num; i++) {
        let score = prompt(`请输入第${i}门科目`);
        score = parseFloat(score);
        if (isNaN(score) || score < 0) {
            alert('分数需要大于0！');
            return;
        }
        all += score;
    }
    alert(`${num}成绩综合为${all}`);
}
statistics();

